package com.yequan.work;

import java.util.*;

/**
 * @author yequan
 * @date 2021/02/20 14:01
 **/
public class SimpleCashCouponDemo {

    public static void main(String[] args) {
        getCashCouponQueue();
    }

    private static void getCashCouponQueue() {
        Queue<SimpleCashCoupon> cashCouponQueue = new PriorityQueue<>(((o1, o2) -> (int) (o2.getPrice() - o1.getPrice())));
        List<SimpleCashCoupon> simpleCashCoupons = new ArrayList<>();
        SimpleCashCoupon simpleCashCoupon1 = new SimpleCashCoupon(1L, 4.1f);
        SimpleCashCoupon simpleCashCoupon2 = new SimpleCashCoupon(2L, 4.9f);
        SimpleCashCoupon simpleCashCoupon3 = new SimpleCashCoupon(4L, 6.4f);
        SimpleCashCoupon simpleCashCoupon4 = new SimpleCashCoupon(6L, 1.0f);
        simpleCashCoupons.add(simpleCashCoupon1);
        simpleCashCoupons.add(simpleCashCoupon2);
        simpleCashCoupons.add(simpleCashCoupon3);
        simpleCashCoupons.add(simpleCashCoupon4);
        for (SimpleCashCoupon simpleCashCoupon : simpleCashCoupons) {
            cashCouponQueue.offer(simpleCashCoupon);
        }
        while (cashCouponQueue.size() > 0) {
            SimpleCashCoupon simpleCashCoupon = cashCouponQueue.poll();
            System.out.println(simpleCashCoupon.getCouponId() + "---" + simpleCashCoupon.getPrice());
        }
    }

}
